<?
  global $compassPosX, $compassPosY, $compassSize, $compassButtonSize;
  $compassPosX = 560;
  $compassPosY = 116;
  $compassButtonSize = 60;
  $compassSize = 180;
  
  $mapDS = DB_GetDatasetMatch('mapstates', array(
    'ms_character' => $this->character->charDS['c_key'],
    'ms_zone' => $this->currentZoneId, 
    ));
  $this->mstats = TextToStringlist($mapDS['ms_state']);
  $this->mstats['xpos'] = getDefault($this->mstats['xpos'], $this->zoneStats['xpos']);
  $this->mstats['ypos'] = getDefault($this->mstats['ypos'], $this->zoneStats['ypos']);
  //$this->mstats['explored.'.$this->mstats['xpos'].'.'.$this->mstats['ypos']] = true;

  $rowCount=8;
  $colCount=10;
  $rowHeight=51;
  $colWidth=55;

  include_once('custom/map.util.php');

?><script><?

  // chart explored territory
  $exAr = array();
  foreach($this->mstats as $k => $v)
  {
    if (CutSegment('.', $k) == 'explored' && $v == true)
      $exAr[] = '"e_'.str_replace('.', '_', $k).'":1';
  }
  print('var exploredAreas = {'.implode(', ', $exAr).'};');
  // account for impassable areas
  $impAr = array();
  gatherCoordRanges($impAr, 'i', $this->zoneStats['impassable']);
  print('var impassableAreas = {'.implode(', ', $impAr).'};');
  // account for locations
  $locAr = array();
  foreach(explode(',', $this->zoneStats['locations']) as $locationId)
  {
    gatherCoordRanges($locAr, 'l', $this->zoneStats[$locationId.'.map'], '"'.$locationId.'"');
  }
  print('var locationAreas = {'.implode(', ', $locAr).'};');

?></script>

<table style="
  position: absolute; left: 0px; top: 90px;
  background: url(img/maps/<?= $this->zoneStats['map'] ?>.png);" width="552" cellpadding="0" cellspacing="0"><?

for($r = 0; $r < $rowCount; $r++)
{
  ?><tr><?
  for($c = 0; $c < $colCount; $c++)
  {
    ?><td><div style="width: <?= $colWidth ?>px; height: <?= $rowHeight ?>px; border-right: 1px solid #a0a0a0; overflow: hidden;
        border-bottom: 1px solid #c0c0c0;" id="cell_<?= $r ?>_<?= $c ?>"></div>
    </td><?
  }
  ?><tr><?
}

?></table>
<div id="compassdiv">
  <div class="compassbutton" style="<?= CButtonPos(0.5, 0) ?>" onclick="MovePlayer(0, -1);"></div>
  <div class="compassbutton" style="<?= CButtonPos(0.5, 1) ?>" onclick="MovePlayer(0, +1);"></div>
  <div class="compassbutton" style="<?= CButtonPos(0, 0.45) ?>" onclick="MovePlayer(-1, 0);"></div>
  <div class="compassbutton" style="<?= CButtonPos(1, 0.45) ?>" onclick="MovePlayer(+1, 0);"></div>
</div>
<div class="compasselement" style="<?= CButtonPos(0.65, 0.55, true) ?>" id="loader_img"><img src="img/icons/ajax-loader.gif"/></div>
<div id="locationdiv"></div>
<div id="lowerbar">
  Your combat team:
  <div id="party_bar"></div>
</div>
<div align="center" id="bar_posupdate"></div>

<script>
  MovePlayer(0, 0);
  $.get('party/ajax_viewparty', function(data) {
    $('#party_bar').html(data);
    });
</script>